package com.ld.wms.utils;

import com.ld.wms.properties.LDProperties;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class ExternalDataUtils {

    @Autowired
    private LDProperties ldProperties;

    /**
     * 获取VOC信息
     */
    public String getVOCData(){
        String sensorUrl = ldProperties.getExternalConfig().getSensorUrl();
        String vocData = HttpUtils.sendPost(sensorUrl, "GCLC_GET,GET_VOC,End;");
        log.info("VOC获取成功：{}", vocData);
        return vocData;
    }

    public String getTemperatureAndHumidity(){
        String sensorUrl = ldProperties.getExternalConfig().getSensorUrl();
        String temperatureAndHumidity = HttpUtils.sendPost(sensorUrl, "GCLC_GET,GET_TEMPHUMI,End;");
        log.info("温湿度获取成功：{}", temperatureAndHumidity);
        return temperatureAndHumidity;
    }

    public String openOrCloseElectronicLock(String param){
        String sensorUrl = ldProperties.getExternalConfig().getSensorUrl();
        return HttpUtils.sendPost(sensorUrl, param);
    }


}
